package com.zte.claa.inficombo.csa.app.service.sapi.ffhost;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;

public class FFDateTime {
	private byte second = 0;
	private byte minute = 0;
	private byte hour = 0;
	private byte day = 1;
	private byte month = 1;
	private byte year = 19;
	
	public FFDateTime(){
		
	}

	public byte getSecond() {
		return second;
	}

	public void setSecond(byte second) {
		this.second = second;
	}

	public byte getMinute() {
		return minute;
	}

	public void setMinute(byte minute) {
		this.minute = minute;
	}

	public byte getHour() {
		return hour;
	}

	public void setHour(byte hour) {
		this.hour = hour;
	}

	public byte getDay() {
		return day;
	}

	public void setDay(byte day) {
		this.day = day;
	}

	public byte getMonth() {
		return month;
	}

	public void setMonth(byte month) {
		this.month = month;
	}

	public byte getYear() {
		return year;
	}

	public void setYear(byte year) {
		this.year = year;
	}
	
	// 获取msg时间的毫秒数.
	public long getMsgTimeOfMillSeconds(){
		// "2007-12-03T10:15:30"
		LocalDateTime dt = LocalDateTime.of(2000+this.year, this.month, this.day, this.hour, this.minute, this.second);
		return dt.toInstant(ZoneOffset.of("+8")).toEpochMilli();
	}
	
	// 设置时间戳.
	public void setMsgTime(long millSeconds){
		Date date = new Date(millSeconds);
		LocalDateTime localDateTime = date.toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime();
		this.year = (byte)(localDateTime.getYear() - 2000);
		this.month = (byte)(localDateTime.getMonthValue());
		this.day = (byte)(localDateTime.getDayOfMonth());
		this.hour = (byte)(localDateTime.getHour());
		this.minute = (byte)(localDateTime.getMinute());
		this.second = (byte)(localDateTime.getSecond());
	}
	
}
